package org.example.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Test8 {
    // 前区号码范围
    private static final int FRONT_AREA_START = 1;
    private static final int FRONT_AREA_END = 35;
    private static final int FRONT_AREA_COUNT = 5;

    // 后区号码范围
    private static final int BACK_AREA_START = 1;
    private static final int BACK_AREA_END = 12;
    private static final int BACK_AREA_COUNT = 2;

    public static void main(String[] args) {
        List<Integer> frontAreaNumbers = generateRandomNumbers(FRONT_AREA_START, FRONT_AREA_END, FRONT_AREA_COUNT);
        List<Integer> backAreaNumbers = generateRandomNumbers(BACK_AREA_START, BACK_AREA_END, BACK_AREA_COUNT);

        System.out.println("大乐透号码生成结果：");
        System.out.println("前区号码: " + frontAreaNumbers);
        System.out.println("后区号码: " + backAreaNumbers);
    }

    /**
     * 生成指定数量且不重复的随机数字
     *
     * @param start    起始数字
     * @param end      结束数字
     * @param count    需要生成的数字数量
     * @return         生成的随机数字列表
     */
    private static List<Integer> generateRandomNumbers(int start, int end, int count) {
        List<Integer> numberList = new ArrayList<>();
        Random random = new Random();

        // 初始化数字列表
        for (int i = start; i <= end; i++) {
            numberList.add(i);
        }

        // 打乱数字列表
        Collections.shuffle(numberList);

        // 取前count个数字
        List<Integer> result = new ArrayList<>(numberList.subList(0, count));

        return result;
    }
}
